<%@ page import="com.lagou.homework.bean.Student" %><%--
  Created by IntelliJ IDEA.
  User: gengxin
  Date: 2020/12/4
  Time: 10:55 上午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生信息管理主页面</title>
    <link href="./css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>

<div class="container">
    <%-- 从session中获取所有学生的数组用于在表格中打印 --%>
    <% Student[] allStudents = (Student[])session.getAttribute("allStudents"); %>
    <table class="table" id="table">
        <caption>
            <h2>学生信息管理</h2>
        </caption>
        <caption>
            <button class="btn btn-info" id="user_add" data-toggle="modal" data-target="#addModal">新增</button>
            <button class="btn btn-info" id="user_delete" data-toggle="modal" data-target="#delModal">删除</button>
            <button class="btn btn-info" id="user_edit" data-toggle="modal" data-target="#myModal">编辑</button>
            <button class="btn btn-info" id="user_find" data-toggle="modal" data-target="#searchModal">查询</button>
            <br><br>
            <form action="showAllStudents" method="POST">
                <button class="btn btn-success" id="user_show" type="submit">显示学生信息</button>
            </form>

        </caption>
        <thead>
        <tr>
            <th>序号</th>
            <th>学号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>出生日期</th>
            <th>邮箱</th>
            <th>备注</th>
        </tr>
        </thead>
        <tbody id="tbody">

            <%
                String color;
                boolean flag = true;
                for (int i = 0; i < allStudents.length; i++) {
                    if (flag) {
                        color = "info";
                    } else {
                        color = "warning";
                    }
            %>
            <tr class= <%= color %> >
                <td style="width:30px;"><input type="checkbox"></td>
                <td id='code'> <%= allStudents[i].getCode() %> </td>
                <td id='userName'> <%= allStudents[i].getUserName() %> </td>
                <td id='sex'> <%= allStudents[i].getSex() %> </td>
                <td id='birthday'> <%= allStudents[i].getBirthday() %> </td>
                <td id='email'> <%= allStudents[i].getEmail() %> </td>
                <td id='note'> <%= allStudents[i].getNote() %> </td>
            </tr>
            <%
                    flag = !flag;//颜色转换
                }
            %>

        </tbody>

    </table>

    <!-- 模态框（Modal） -->

    <!-- 新增用户模态框 -->
    <div class="modal " id="addModal" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
                <form action="addStudent" method="POST">

                    <div class="modal-header">
                        <button class="close" data-dismiss="modal" aria-hidden="true">
                            <span>&times;</span>
                        </button>
                        <h4 class="modal-title" id="addModalLabel">
                            新增用户
                        </h4>
                    </div>

                    <div class="modal-body" id="modal-body-add">
                        <label>学号:</label>
                        <input type="text" class="form-control" id="add_code" name="add_code" placeholder="请输入学号">
                        <label>姓名:</label>
                        <input type="text" class="form-control" id="add_userName" name="add_userName" placeholder="请输入姓名">
                        <label>性别:</label>
                        <input type="text" class="form-control" id="add_sex" name="add_sex" placeholder="请输入性别">
                        <label>出生日期:</label>
                        <input type="text" class="form-control" id="add_birthday" name="add_birthday" placeholder="请输入出生日期">
                        <label>邮箱:</label>
                        <input type="text" class="form-control" id="add_email" name="add_email" placeholder="请输入邮箱">
                        <label>备注:</label>
                        <input type="text" class="form-control" id="add_note" name="add_note" placeholder="请输入备注信息">
                    </div>

                    <div class="modal-footer">
                        <button id="saveAdd" class="btn btn-default" type="reset">重设</button>
                        <button type="submit" class="btn btn-primary" onclick="alert('添加成功！')">提交更改</button>
                    </div>

                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <%-- 编辑用户模态框 --%>
    <div class="modal " id="myModal" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
                <form action="editServlet" method="POST">

                    <div class="modal-header">
                        <button class="close" data-dismiss="modal" aria-hidden="true">
                            <span>&times;</span>
                        </button>
                        <h4 class="modal-title" id="editModalLabel">
                            编辑用户
                        </h4>
                    </div>

                    <div class="modal-body" id="modal-body">
                        <label>已选中的学生学号:</label>
                        <input type="text" class="form-control" id="m_code" name="m_code" readonly="readonly" placeholder="请输入学号">
                        <label>姓名:</label>
                        <input type="text" class="form-control" id="m_userName" name="m_userName" placeholder="请输入姓名">
                        <label>性别:</label>
                        <input type="text" class="form-control" id="m_sex" name="m_sex" placeholder="请输入性别">
                        <label>出生日期:</label>
                        <input type="text" class="form-control" id="m_birthday" name="m_birthday" placeholder="请输入出生日期">
                        <label>邮箱:</label>
                        <input type="text" class="form-control" id="m_email" name="m_email" placeholder="请输入邮箱">
                        <label>备注:</label>
                        <input type="text" class="form-control" id="m_note" name="m_note" placeholder="请输入备注信息">
                    </div>

                    <div class="modal-footer">
                        <button id="save" class="btn btn-default" type="reset">重设</button>
                        <button type="submit" class="btn btn-primary" onclick="alert('修改成功！')">提交更改</button>
                    </div>

                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <%-- 删除用户模态框 --%>
    <div class="modal " id="delModal" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
                <form action="delServlet" method="POST">

                    <div class="modal-header">
                        <button class="close" data-dismiss="modal" aria-hidden="true">
                            <span>&times;</span>
                        </button>
                        <h4 class="modal-title" id="delModalLabel">
                            删除用户
                        </h4>
                    </div>

                    <div class="modal-body" id="modal-body-del">
                        <label>确定删除以下学号的用户吗？</label>
                        <input type="text" class="form-control" id="del" name="del" readonly="readonly">

                    </div>

                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary" onclick="alert('删除成功！')">确定</button>
                    </div>

                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <%-- 查询用户模态框 --%>
    <div class="modal " id="searchModal" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
                <form action="searchServlet" method="POST">

                    <div class="modal-header">
                        <button class="close" data-dismiss="modal" aria-hidden="true">
                            <span>&times;</span>
                        </button>
                        <h4 class="modal-title" id="searchModalLabel">
                            查询用户
                        </h4>
                    </div>

                    <div class="modal-body" id="modal-body-search">
                        <label>请输入要查询的学号</label>
                        <input type="text" class="form-control" id="search" name="search">

                    </div>

                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary">查询</button>
                    </div>

                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

</div>

<script type="text/javascript" src="./js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="./js/bootstrap.min.js"></script>
<script type="text/javascript" src="./js/ref.js"></script>
</body>
</html>
